﻿@model KPIS.GERP.Models.ICM.DeliveryNote

@{
    //Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "ตรวจรับพัสดุ [DN]";
    ViewBag.Descr = "กรอกรายการหลักการตรวจรับ";
    
     
}




@using (Html.BeginForm("Create", "DeliveryNote", FormMethod.Post, new {  @class = "form-horizontal" }))
  
  {
       @Html.AntiForgeryToken()

     <div class="block-button-menu-above">
         <a class="btn button-standard-width btn-small btn-gray" data-rel="tooltip" href="#" onclick="window.location.href='@Url.Action("indexNotDelivery", "DeliveryNote")'" role="button">
             <i class="icon-reply bigger-120"></i>&nbsp;&nbsp;กลับไปหน้าแสดงข้อมูลการรายการส่งมอบที่ยังไม่ตรวจรับ
         </a>
         <a class="btn button-standard-width btn-small btn-gray" data-rel="tooltip" href="#" onclick="window.location.href = '@Url.Action("Index", "DeliveryNote")'" role="button">
             <i class="icon-reply bigger-120"></i>&nbsp;&nbsp;กลับไปหน้าแสดงข้อมูลการตรวจรับ
         </a>
            @Html.ButtonSubmit()
        </div>
    @Html.Partial("_EditForm")
  }
@section Scripts {
    

<script type="text/javascript" >

    $('.date-picker').datepicker({ language: 'th-th', format: 'dd/mm/yyyy' });

    //$("form").submit(function (e) {
    //    e.preventDefault();
    //    var currentForm = this;
    //    bootbox.confirm("ต้องการบันทึก ใช่หรือไม่?", function (result) {
    //        if (result) {
    //            currentForm.submit();
    //        }
    //    });
    //});

        $(function () {
            $("form").submit(function (e) {
                var currentForm = this;
                bootbox.confirm(function (result) {
                    var _result = result;
                    if (result) {
                        $.ajax({
                            url: currentForm.action,
                            type: currentForm.method,
                            data: $(currentForm).serialize(),
                            success: function (result) {
                                if (result.result) {
                                    bootbox.alert(result.message, "ตกลง", function () {
                                        // closeModal();
                                        bootbox.hideAll();
                                        window.location = '@Url.Action("Index", "DeliveryNote")';
                                    });
                                }
                                else {
                                    bootbox.alert(result.message, "ตกลง", function () {
                                        bootbox.hideAll();
                                        reload();
                                    });
                                }
                            }
                        });

                        return false;
                    }
                });

                return false;
            });

            $(".chzn-select").chosen({ width: '220px' }); 

            $("#lblPoRequireDate").hide();
        });

    function closeModal() {
        var $jParent = window.parent.jQuery.noConflict();
        $jParent('#modal').modal('hide');
    }
    </script>
   
}